home *** CD-ROM | disk | FTP | other *** search
- Path: castle.nando.net!news
- From: Caius Martius <caius@nando.net>
- Newsgroups: comp.lang.c++
- Subject: Re: Why does this work?
- Date: Wed, 27 Mar 1996 17:27:33 -0800
- Organization: Carolantic Realty, Inc.
- Message-ID: <3159EB05.4E1C@nando.net>
- References: <DoxvnA.L0C@mail.auburn.edu>
- NNTP-Posting-Host: vyger1215.nando.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I; 16bit)
-
- John M. Greer wrote:
- >
- > This is probably a horribly simple question, but I was going through a
- > few books, brushing up on my iostreams, when I saw this tidbit in Jamsa's
- > Multimedia Trilogy (The CD-ROM by Kris Jamsa)
- >
- > #include <iostream.h>
- > #include <ctype.h>
- >
- > void main(void)
- > {
- > char letter;
- >
- > while (! cin.eof())
- > {
- > letter = cin.get();
- > letter = toupper(letter);
- > cout << letter;
- > }
- > }
- >
- > Why does this work!?!? It seems to reserve storage for only one
- > character in letter, but outputs a whole line at a time. Feel free to
- > flame my stupidity, but please satisfy my curiosity (I'm really not this
- > clueless, I promise!!)
- >
- > John Greer
-
- To further explain, when you run the program and type a word, the word is
- not stored in letter. Instead the word is stored in the stream buffer
- and is read one character at a time by get().
-